﻿using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Text;

namespace PickGold.Api
{
	/// <summary>
	/// 
	/// </summary>
	public static class Ole32
	{
		/// <summary>
		/// 
		/// </summary>
		public const string DLL = ApiUtil.DLL_OLE32;

		/// <summary>
		/// 
		/// </summary>
		/// <param name="clsid"></param>
		/// <param name="punkOuter"></param>
		/// <param name="context"></param>
		/// <param name="iid"></param>
		/// <returns></returns>
		[return: MarshalAs(UnmanagedType.Interface)]
		[DllImport(DLL, ExactSpelling = true, PreserveSig = false)]
		public static extern object CoCreateInstance([In] ref Guid clsid, [MarshalAs(UnmanagedType.Interface)] object punkOuter, int context, [In] ref Guid iid);

		/// <summary>
		/// 
		/// </summary>
		/// <param name="clsid"></param>
		/// <param name="punkOuter"></param>
		/// <param name="context"></param>
		/// <param name="iid"></param>
		/// <returns></returns>
		[DllImport(DLL, ExactSpelling = true, PreserveSig = false)]
		public static extern IntPtr CoCreateInstance([In] ref Guid clsid, IntPtr punkOuter, int context, [In] ref Guid iid);

		/// <summary>
		/// 
		/// </summary>
		/// <param name="clsid"></param>
		/// <param name="punkOuter"></param>
		/// <param name="context"></param>
		/// <param name="iid"></param>
		/// <param name="pVoid"></param>
		/// <returns></returns>
		[DllImport(DLL, ExactSpelling = true)]
		public static extern int CoCreateInstance([In] ref Guid clsid, IntPtr punkOuter, int context, [In] ref Guid iid, [Out] out IntPtr pVoid);

		/// <summary>
		/// 
		/// </summary>
		/// <param name="clsid"></param>
		/// <param name="punkOuter"></param>
		/// <param name="context"></param>
		/// <param name="iid"></param>
		/// <param name="pVoid"></param>
		/// <returns></returns>
		[DllImport(DLL, ExactSpelling = true)]
		public static extern int CoCreateInstance([In] ref Guid clsid, [MarshalAs(UnmanagedType.Interface)] object punkOuter, int context, [In] ref Guid iid, [MarshalAs(UnmanagedType.Interface), Out] out object pVoid);

		/// <summary>
		/// ?文件摘要信息
		/// </summary>
		/// <param name="name"></param>
		/// <param name="accessMode"></param>
		/// <param name="storageFileFormat"></param>
		/// <param name="fileBuffering"></param>
		/// <param name="options"></param>
		/// <param name="reserved"></param>
		/// <param name="riid"></param>
		/// <param name="propertySetStorage"></param>
		/// <returns></returns>
		[DllImport(DLL, CharSet = CharSet.Unicode)]
		public static extern uint StgCreateStorageEx([MarshalAs(UnmanagedType.LPWStr)] string name, int accessMode, int storageFileFormat, int fileBuffering, IntPtr options, IntPtr reserved, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] ref IPropertySetStorage propertySetStorage);

		/// <summary>
		/// ?文件摘要信息
		/// </summary>
		/// <param name="name"></param>
		/// <param name="accessMode"></param>
		/// <param name="storageFileFormat"></param>
		/// <param name="fileBuffering"></param>
		/// <param name="options"></param>
		/// <param name="reserved"></param>
		/// <param name="riid"></param>
		/// <param name="propertySetStorage"></param>
		/// <returns></returns>
		[DllImport(DLL, CharSet = CharSet.Unicode)]
		public static extern uint StgOpenStorageEx([MarshalAs(UnmanagedType.LPWStr)] string name, int accessMode, int storageFileFormat, int fileBuffering, IntPtr options, IntPtr reserved, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] ref IPropertySetStorage propertySetStorage);
	}
}
